<Project Sdk="Microsoft.DotNet.Helix.Sdk" DefaultTargets="Test">

  <ItemGroup>
    <HelixCorrelationPayload Include="$(CorrelationPayloadDirectory)">
      <PayloadDirectory>%(Identity)</PayloadDirectory>
    </HelixCorrelationPayload>
  </ItemGroup>

  <!-- 
    Crossgen and Crossgen2 Scenario WorkItems 
  -->
  <PropertyGroup Condition="'$(AGENT_OS)' == 'Windows_NT'">
    <Python>py -3</Python>
    <HelixPreCommands>$(HelixPreCommands)</HelixPreCommands>
    <CoreRoot>%HELIX_CORRELATION_PAYLOAD%\Core_Root</CoreRoot>
    <ScenarioDirectory>%HELIX_CORRELATION_PAYLOAD%\performance\src\scenarios\</ScenarioDirectory>
    <CrossgenDirectory>$(ScenarioDirectory)crossgen\</CrossgenDirectory>
    <Crossgen2Directory>$(ScenarioDirectory)crossgen2\</Crossgen2Directory>
  </PropertyGroup>
  <PropertyGroup Condition="'$(AGENT_OS)' != 'Windows_NT'">
    <Python>python3</Python>
    <HelixPreCommands>$(HelixPreCommands);chmod +x $HELIX_WORKITEM_PAYLOAD/startup/Startup;chmod +x $HELIX_WORKITEM_PAYLOAD/startup/perfcollect;sudo apt update;chmod +x $HELIX_WORKITEM_PAYLOAD/SOD/SizeOnDisk</HelixPreCommands>
    <CoreRoot>$HELIX_CORRELATION_PAYLOAD/Core_Root</CoreRoot>
    <ScenarioDirectory>$HELIX_CORRELATION_PAYLOAD/performance/src/scenarios/</ScenarioDirectory>
    <CrossgenDirectory>$(ScenarioDirectory)crossgen/</CrossgenDirectory>
    <Crossgen2Directory>$(ScenarioDirectory)crossgen2/</Crossgen2Directory>
  </PropertyGroup>

  <ItemGroup>
    <SingleAssembly Include="System.Net.WebProxy.dll"/>                 <!-- Approx. 10 KB as of 2020/10 -->
    <SingleAssembly Include="System.Net.Http.Json.dll"/>                <!-- Approx. 20 KB as of 2020/10 -->
    <SingleAssembly Include="System.Drawing.Primitives.dll"/>           <!-- Approx. 50 KB as of 2020/10 -->
    <SingleAssembly Include="System.ServiceModel.Syndication.dll"/>     <!-- Approx. 100 KB as of 2020/10 -->
    <SingleAssembly Include="System.Net.Sockets.dll"/>                  <!-- Approx. 200 KB as of 2020/10 -->
    <SingleAssembly Include="System.Linq.Expressions.dll"/>             <!-- Approx. 500 KB as of 2020/10 -->
    <SingleAssembly Include="System.Data.Common.dll"/>                  <!-- Approx. 1 MB as of 2020/10 -->
    <SingleAssembly Include="Microsoft.CodeAnalysis.dll"/>              <!-- Approx. 2 MB as of 2020/10 -->
    <SingleAssembly Include="System.Private.Xml.dll"/>                  <!-- Approx. 3 MB as of 2020/10 -->
    <SingleAssembly Include="Microsoft.CodeAnalysis.VisualBasic.dll"/>  <!-- Approx. 4 MB as of 2020/10 -->
    <SingleAssembly Include="Microsoft.CodeAnalysis.CSharp.dll"/>       <!-- Approx. 4 MB as of 2020/10 -->
    <SingleAssembly Include="System.Private.CoreLib.dll"/>              <!-- Approx. 10 MB as of 2020/10 -->
  </ItemGroup>
  <ItemGroup>
    <Composite Include="framework-r2r.dll.rsp"/>
  </ItemGroup>

  <ItemGroup> 
    <Crossgen2WorkItem Include="@(SingleAssembly)">
      <PayloadDirectory>$(WorkItemDirectory)</PayloadDirectory>
      <Command>$(Python) $(Crossgen2Directory)test.py crossgen2 --core-root $(CoreRoot) --single %(Identity)</Command>
    </Crossgen2WorkItem>
  </ItemGroup>

  <ItemGroup> 
    <Crossgen2SingleThreadedWorkItem Include="@(SingleAssembly)">
      <PayloadDirectory>$(WorkItemDirectory)</PayloadDirectory>
      <Command>$(Python) $(Crossgen2Directory)test.py crossgen2 --core-root $(CoreRoot) --single %(Identity) --singlethreaded True</Command>
    </Crossgen2SingleThreadedWorkItem>
  </ItemGroup>

  <ItemGroup>
    <Crossgen2SizeOnDiskWorkItem Include="@(SingleAssembly)">
      <PayloadDirectory>$(WorkItemDirectory)</PayloadDirectory>
      <PreCommands>$(Python) $(Crossgen2Directory)pre.py crossgen2 --core-root $(CoreRoot) --single %(Identity) </PreCommands>
      <Command>$(Python) $(Crossgen2Directory)test.py sod --scenario-name &quot;Crossgen2 %(Identity) Size&quot; --dirs ./crossgen.out/</Command>
      <PostCommands>$(Python) $(Crossgen2Directory)post.py</PostCommands>
    </Crossgen2SizeOnDiskWorkItem>
  </ItemGroup>

  <ItemGroup>
    <!-- Enable crossgen2 tests on Windows x64 and Linux x64 -->
    <HelixWorkItem Include="@(Crossgen2WorkItem -> 'Crossgen2 %(Identity)')">
      <Timeout>4:00</Timeout>
    </HelixWorkItem>
    <HelixWorkItem Include="@(Crossgen2SingleThreadedWorkItem -> 'Crossgen2 single-threaded %(Identity)')">
      <Timeout>4:00</Timeout>
    </HelixWorkItem>
    <HelixWorkItem Include="Crossgen2 Composite Framework R2R">
      <PayloadDirectory>$(WorkItemDirectory)</PayloadDirectory>	
      <Command>$(Python) $(Crossgen2Directory)test.py crossgen2 --core-root $(CoreRoot) --composite $(Crossgen2Directory)framework-r2r.dll.rsp</Command>
      <Timeout>1:00</Timeout>  
    </HelixWorkItem>
    <HelixWorkItem Include="@(Crossgen2SizeOnDiskWorkItem -> 'Crossgen2 Size on Disk %(Identity)')">
      <Timeout>4:00</Timeout>  
    </HelixWorkItem>
  </ItemGroup>
</Project>
